﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using XLCS.Common;

namespace WPF_DbCenter.UI
{
    /// <summary>
    /// Interaction logic for Options.xaml
    /// </summary>
    public partial class Options : BaseUI.BaseFadeDialog
    {
        public enum MainIDEStyle
        {
            Old,
            Normal,
        };
        public MainIDEStyle CurMainIDEStyle { get; set; }

        public Options()
        {
            InitializeComponent();
            WindowStartupLocation = WindowStartupLocation.CenterOwner;

            this.comboBox1.Items.Add(MainIDEStyle.Old);
            this.comboBox1.Items.Add(MainIDEStyle.Normal);
            this.checkBox1.IsChecked = Properties.Settings.Default.AutoBackupOldVersionFileBeforeUpgrade;
            this.comboBox1.SelectedIndex = (int)Properties.Settings.Default.StartMainIDEStep;
        }

        private void butOK_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (comboBox1.SelectedItem == null)
                {
                    Properties.Settings.Default["StartMainIDEStep"] = 0;
                }
                else
                {
                    switch ((MainIDEStyle)comboBox1.SelectedItem)
                    {
                        case MainIDEStyle.Old:
                            Properties.Settings.Default.StartMainIDEStep = 0;
                            break;
                        case MainIDEStyle.Normal:
                            Properties.Settings.Default.StartMainIDEStep = 1;
                            break;
                        default:
                            Properties.Settings.Default.StartMainIDEStep = 0;
                            break;
                    }
                }
                Properties.Settings.Default["AutoBackupOldVersionFileBeforeUpgrade"] = (bool)checkBox1.IsChecked;
                Properties.Settings.Default.Save();

                Close();
            }
            catch (Exception ee)
            {
                ProcessException.DisplayErrors(ee);
            }
        }
    }
}
